package com.hht.study.proxy.dynamic.jdk;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @author hht
 * @date 2022/3/6
 */
public class MyInvocationHandler implements InvocationHandler {

    /**
     * 被动态代理的真实对象
     */
    private final Object target;

    MyInvocationHandler(Object target){
        this.target=target;
    }


    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

        System.out.println("Jdk动态代理增强，执行方法--"+method.getName());
        //执行真实方法
        Object invoke = method.invoke(target, args);
        return invoke;
    }
}
